import config from "@/config"
import http from "@/utils/request"

export default {
	project: {
		url: `${config.API_URL}/design/project`,
		name: "项目管理",
		get: async function(params){
			return await http.get(this.url, params);
		},
		post: async function(data){
			return await http.post(this.url, data);
		},
		put: async function(data){
			return await http.put(this.url + `/${data.id}`, data);
		},
		delete: async function(id){
			return await http.delete(this.url + `/${id}`);
		},
		exists: async function(fieldName, fieldValue, id) {
			return await http.get(this.url + `/exists/${fieldName}/${fieldValue}/${id}`);
		}
	},
	projectDict: {
		url: `${config.API_URL}/design/project-dict`,
		name: "项目管理",
		get: async function(params){
			return await http.get(this.url, params);
		},
		post: async function(data){
			return await http.post(this.url, data);
		},
		put: async function(data){
			return await http.put(this.url + `/${data.id}`, data);
		},
		delete: async function(id){
			return await http.delete(this.url + `/${id}`);
		},
		exists: async function(fieldName, fieldValue, id) {
			return await http.get(this.url + `/exists/${fieldName}/${fieldValue}/${id}`);
		}
	},
	database: {
		url: `${config.API_URL}/design/database`,
		name: "数据库管理",
		get: async function(params){
			return await http.get(this.url, params);
		},
		post: async function(data){
			return await http.post(this.url, data);
		},
		put: async function(data){
			return await http.put(this.url + `/${data.id}`, data);
		},
		delete: async function(id){
			return await http.delete(this.url + `/${id}`);
		},
		exists: async function(fieldName, fieldValue, id) {
			return await http.get(this.url + `/exists/${fieldName}/${fieldValue}/${id}`);
		}
	},
	module: {
		url: `${config.API_URL}/design/module`,
		name: "模块管理",
		get: async function(params){
			return await http.get(this.url, params);
		},
		post: async function(data){
			return await http.post(this.url, data);
		},
		put: async function(data){
			return await http.put(this.url + `/${data.id}`, data);
		},
		delete: async function(id){
			return await http.delete(this.url + `/${id}`);
		},
		exists: async function(fieldName, fieldValue, id) {
			return await http.get(this.url + `/exists/${fieldName}/${fieldValue}/${id}`);
		}
	},
	table: {
		url: `${config.API_URL}/design/table`,
		name: "表管理",
		get: async function(params){
			return await http.get(this.url, params);
		},
		post: async function(data){
			return await http.post(this.url, data);
		},
		put: async function(data){
			return await http.put(this.url + `/${data.id}`, data);
		},
		delete: async function(id){
			return await http.delete(this.url + `/${id}`);
		},
		exists: async function(fieldName, fieldValue, id) {
			return await http.get(this.url + `/exists/${fieldName}/${fieldValue}/${id}`);
		}
	},
	tableColumn: {
		url: `${config.API_URL}/design/table-column`,
		name: "表字段管理",
		get: async function(params){
			return await http.get(this.url, params);
		},
		post: async function(data){
			return await http.post(this.url, data);
		},
		put: async function(data){
			return await http.put(this.url + `/${data.id}`, data);
		},
		delete: async function(id){
			return await http.delete(this.url + `/${id}`);
		},
		exists: async function(fieldName, fieldValue, id) {
			return await http.get(this.url + `/exists/${fieldName}/${fieldValue}/${id}`);
		}
	}
}
